package com.study.rabbitmq.basic.key;

import com.rabbitmq.client.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class KeyProducerTest {
	public static void main(String[] args) throws IOException, TimeoutException, InterruptedException {
		ConnectionFactory factory = new ConnectionFactory();
		factory.setHost("192.168.20.68");
		factory.setPort(5672);
		factory.setUsername("leke");
		factory.setPassword("leke@@@");

		Connection connection = factory.newConnection();
		Channel channel = connection.createChannel(5);

		String exchangeName = "mytopicexchange";
		String queueName = "keyQueue";
		String bindingKey = "a.b.c";

		channel.queueDeclare(queueName,false,false,false,null);
		channel.exchangeDeclare(exchangeName,"topic",false,false,null);
		channel.queueBind(queueName, exchangeName, bindingKey);

		String queueName1 = "keyQueue1";
		String bindingKey1 = "a.b.d";

		channel.queueDeclare(queueName1,false,false,false,null);
		channel.queueBind(queueName1, exchangeName, bindingKey1);
		channel.basicPublish(exchangeName,"a.b.*",null,"xxxxxx".getBytes());

	}
}
